package com.cyx.friend.controller.exam;

import com.cyx.common.core.controller.BaseController;
import com.cyx.common.core.domain.R;
import com.cyx.common.core.domain.TableDataInfo;
import com.cyx.friend.domain.exam.dto.ExamQueryDTO;
import com.cyx.friend.service.exam.IExamService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/exam")
@Tag(name = "C端竞赛列表功能")
public class ExamController extends BaseController {

    @Autowired
    private IExamService examService;

    // semiLogin代表支持游客登录
    @Operation(description = "竞赛列表")
    @GetMapping("semiLogin/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO) {
        return getTableDataInfo(examService.list(examQueryDTO));
    }

    // semiLogin代表支持游客登录
    @Operation(description = "竞赛列表")
    @GetMapping("semiLogin/redis/list")
    public TableDataInfo redisList(ExamQueryDTO examQueryDTO) {
        return examService.redisList(examQueryDTO);
    }

    @GetMapping("/getFirstQuestion")
    public R<String> getFirstQuestion(Long examId) {
        return R.ok(examService.getFirstQuestion(examId));
    }

    @GetMapping("/pre/question")
    public R<String> preQuestion(Long examId, Long questionId) {
        return R.ok(examService.preQuestion(examId, questionId));
    }

    @GetMapping("/next/question")
    public R<String> nextQuestion(Long examId, Long questionId) {
        return R.ok(examService.nextQuestion(examId, questionId));
    }
}
